<template>
    <div>
      用户列表
      {{id}}
    </div>
</template>

<script>
    export default {
        props: ["id"],
        name: "List.vue",
        beforeRouteEnter: ((to, from, next) => {
          console.log("页面进入前...");
          //只有这一个地方可以拿到vue实例，设置回调
          next(vm =>{
            vm.getData();
          });
        }),
        beforeRouteLeave: (to, from, next) => {
          console.log("页面离开前...");
          next();//跳到下一个路由
        },
        methods: {
          getData: function () {
            this.axios({
              type: 'get',
              url: 'http://localhost:8080/static/data.json',
            }).then(response => {
              console.log(response);
            }).catch(error =>{
              console.log(error);
            })
          }
        }
    }
</script>

<style scoped>

</style>
